<template>
  <div>
    <el-header height="200px">
      <div class="infoShow">
        <infoleft></infoleft>
        <div class="infoRight">
          <div>
            <div class="myCourse">
              <div>年龄</div>
              <div class="myCourseNum">{{ Math.round((new Date()-(Date.parse(this.$store.state.student.birthday)))/1000/60/60/24/365) }}</div>
            </div>
            <div class="myCourse">
              <div>性别</div>
              <div class="myCourseNum">{{this.$store.state.student.gender}}</div>
            </div>
            <div class="myCourse">
              <div>星座</div>
              <div class="myCourseNum">{{this.constellation}}</div>
            </div>
          </div>
        </div>
      </div>
    </el-header>
  </div>
</template>
<script>
import infoleft from "./studentinfoleft";

export default {
  name: "studentinforightinfo",
  components:{
    'infoleft':infoleft,
  },
  data(){
    return {
      birthday:'',
      constellation:''
    }
  },
  created() {
    this.birthday = this.$store.state.student.birthday;
    let birthday = this.birthday.split("-");
    let month = birthday[1]-0;
    let day = birthday[2]-0;
    let xingzuo = ["魔羯座","水瓶座", "双鱼座", "牧羊座",
      "金牛座", "双子座", "巨蟹座", "狮子座", "处女座", "天秤座", "天蝎座", "射手座" ];
    let month22 = [22, 20, 19, 21, 21, 21, 22, 23, 23, 23, 23, 22];  // 两个星座分割日
    let index = month;
    // 所查询日期在分割日之前，索引-1，否则不变
    if (day < month22[month - 1]) {
      index = index - 1;
    }
    // 返回索引指向的星座string
    this.constellation = xingzuo[index];
  }
}
</script>

<style scoped>
@import "../../assets/css/student.css";
</style>
